Subroutines vs. Macros

Although subroutines and macros work similarly, they have subtle differences. Any logic may use both macros and subroutines. The main difference is in the way they are used. Only subroutines can be used when you need to pass arguments, get a return value, or activate the independent execution of logic. Only macros can be used when defining run-time interface parameters.

Macros may be used in any expression field, but the macro may only contain an expression (i.e., Entries(LOC1), U(5,1)). When a macro is used in a logic field, the macro may include any logic element valid in that logic field.

Subroutines may also be used in an expression field provided that the RETURN statement is used to return a value to the expression field. When a subroutine is used to represent one or more logic statements, the subroutine may only include statements valid for the particular context.